package com.example.test.责任连;

/**
 * @author hzj@jovision.com
 * @Date 2020/12/5 上午10:59
 * @Description TODO
 */
public abstract class AbstractSourceHandler {

    protected AbstractSourceHandler successor;

    public void setNext(AbstractSourceHandler successor) {
        this.successor = successor;
    }

    public final void handle() {
        boolean handled = doHandle();
        if (handled && this.successor != null) {
            this.successor.handle();
        }
    }

    protected abstract boolean doHandle();
}
